//
//  DiscoverViewController.m
//  oschina_song
//
//  Created by song on 16/1/25.
//  Copyright © 2016年 song. All rights reserved.
//

#import "DiscoverViewController.h"
#import "RESideMenu.h"
#import "EventsViewController.h"
#import "PersonSearchViewController.h"
#import "ScanViewController.h"
#import "ShakingViewController.h"
#import "SwipableViewController.h"
#import "ActivitiesViewController.h"

@interface DiscoverViewController ()

@end

@implementation DiscoverViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (IBAction)menuClick:(UIBarButtonItem *)sender {
    [self.sideMenuViewController presentLeftMenuViewController];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell =[ UITableViewCell new];
    
    switch (indexPath.section) {
        case 0:
            cell.textLabel.text = @"好友圈";
            cell.imageView.image =[UIImage imageNamed:@"discover-events"];
            break;
        case 1:
            cell.textLabel.text =@[@"找人", @"活动"][indexPath.row];
            cell.imageView.image =[UIImage imageNamed:@[@"discover-search", @"discover-activities"][indexPath.row]];
            break;
            
        case 2:
            cell.textLabel.text =@[@"扫一扫", @"摇一摇"][indexPath.row];
            cell.imageView.image =[UIImage imageNamed:@[@"discover-scan", @"discover-shake"][indexPath.row]];
            break;
        default:
            break;
    }
    
    return  cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.section) {
        case 0:
        {
            EventsViewController *eventViewCtl = [EventsViewController new];
            [self.navigationController pushViewController:eventViewCtl animated:YES];
            break;
        }
            
        case 1:
            if(indexPath.row == 0)
            {
                PersonSearchViewController *personViewCtl = [PersonSearchViewController new];
                [self.navigationController pushViewController:personViewCtl animated:YES];
                break;
            }else if (indexPath.row == 1)
            {
                SwipableViewController *activitySVC =[[ SwipableViewController alloc] initWithTitle:@"活动" addSubTitles:@[@"近期活动",@"我的活动"] andControllers:@[[ActivitiesViewController new],[ActivitiesViewController new] ]];
                
                
                [self.navigationController pushViewController:activitySVC animated:YES];
                break;
            }
            
            
        case 2:
            if(indexPath.row ==0)
            {
                ScanViewController *scanVC = [ScanViewController new];
                UINavigationController *navCtl =[[UINavigationController alloc] initWithRootViewController:scanVC];
                [self.navigationController presentViewController:navCtl animated:YES completion:nil];
                break;
            }else if(indexPath.row ==1)
            {
                [self.navigationController pushViewController:[ShakingViewController new] animated:YES];
               break;
            }
            
        default:
            break;
    }

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return  23;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
{
    return  45;
}


@end
